// System Unit
// ShortString Support

(*************)
(* Interface *)
(*************)
{$IFDEF Include_Modules_Header}

 Type
  PShortString = ^ShortString;

 Function _PStrCmp(Const Left, Right: ShortString): Integer;
 Type RTLProc_PStrCmp = Function(Const Left, Right: ShortString): Integer;

 Procedure _PStrCpy(Dest: PShortString; Source: PShortString);
 Type RTLProc_PStrCpy = Procedure(Dest: PShortString; Source: PShortString);

 Procedure _PStrNCpy(Dest: PShortString; Source: PShortString; MaxLen: Byte);
 Type RTLProc_PStrNCpy = Procedure(Dest: PShortString; Source: PShortString; MaxLen: Byte);

 Procedure _PStrCat(Dest: PShortString; Const Src: ShortString);
 Type RTLProc_PStrCat = Procedure(Dest: PShortString; Const Src: ShortString);

 Procedure _PStrNCat(Dest: PShortString; Const Src: ShortString; Size: Integer);
 Type RTLProc_PStrNCat = Procedure(Dest: PShortString; Const Src: ShortString; Size: Integer);

 Function _Copy(Const S: ShortString; Index, Count: Integer): ShortString;
 Type RTLProc_Copy = Function(Const S: ShortString; Index, Count: Integer): ShortString;

 Procedure _Delete(Var S: OpenString; Index, Count: Integer);
 Type RTLProc_Delete = Procedure(Var S: OpenString; Index, Count: Integer);

 Procedure _Insert(Const Source: ShortString; Var S: OpenString; Index: Integer);
 Type RTLProc_Insert = Procedure(Const Source: ShortString; Var S: OpenString; Index: Integer);

 Procedure _SetLength(S: PShortString; newLength: Byte);
 Type RTLProc_SetLength = Procedure(S: PShortString; newLength: Byte);

 Procedure _SetString(S: PShortString; buffer: PAnsiChar; len: Byte);
 Type RTLProc_SetString = Procedure(S: PShortString; buffer: PAnsiChar; len: Byte);

 //==================
 // RTL Extensions
 //==================
 Type
  TRTLEx_ShortString = Record
   _PStrCmp: RTLProc_PStrCmp;
   _PStrCpy: RTLProc_PStrCpy;
   _PStrNCpy: RTLProc_PStrNCpy;
   _PStrCat: RTLProc_PStrCat;
   _PStrNCat: RTLProc_PStrNCat;
   _Copy: RTLProc_Copy;
   _Delete: RTLProc_Delete;
   _Insert: RTLProc_Insert;
   _SetLength: RTLProc_SetLength;
   _SetString: RTLProc_SetString;
  END;

 Procedure RTLExtend_ShortString(Var Ex: TRTLEx_ShortString);

{$ENDIF Include_Modules_Header}
(******************)
(* Implementation *)
(******************)
{$IFDEF Include_Modules_Implement}

 Function _RTL_PStrCmp(Const Left, Right: ShortString): Integer;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_PStrCpy(Dest: PShortString; Source: PShortString);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_PStrNCpy(Dest: PShortString; Source: PShortString; MaxLen: Byte);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_PStrCat(Dest: PShortString; Const Src: ShortString);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_PStrNCat(Dest: PShortString; Const Src: ShortString; Size: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_Copy(Const S: ShortString; Index, Count: Integer): ShortString;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_Delete(Var S: OpenString; Index, Count: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_Insert(Const Source: ShortString; Var S: OpenString; Index: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_SetLength(S: PShortString; newLength: Byte);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_SetString(S: PShortString; buffer: PAnsiChar; len: Byte);
  ASM
   JMP _INT_NotImplemented
  END;

 Var
  RTL_PStrCmp: RTLProc_PStrCmp = _RTL_PStrCmp;
  RTL_PStrCpy: RTLProc_PStrCpy = _RTL_PStrCpy;
  RTL_PStrNCpy: RTLProc_PStrNCpy = _RTL_PStrNCpy;
  RTL_PStrCat: RTLProc_PStrCat = _RTL_PStrCat;
  RTL_PStrNCat: RTLProc_PStrNCat = _RTL_PStrNCat;
  RTL_Copy: RTLProc_Copy = _RTL_Copy;
  RTL_Delete: RTLProc_Delete = _RTL_Delete;
  RTL_Insert: RTLProc_Insert = _RTL_Insert;
  RTL_SetLength: RTLProc_SetLength = _RTL_SetLength;
  RTL_SetString: RTLProc_SetString = _RTL_SetString;

 Function _PStrCmp(Const Left, Right: ShortString): Integer;
  ASM
   JMP RTL_PStrCmp
  END;

 Procedure _PStrCpy(Dest: PShortString; Source: PShortString);
  ASM
   JMP RTL_PStrCpy
  END;

 Procedure _PStrNCpy(Dest: PShortString; Source: PShortString; MaxLen: Byte);
  ASM
   JMP RTL_PStrNCpy
  END;

 Procedure _PStrCat(Dest: PShortString; Const Src: ShortString);
  ASM
   JMP RTL_PStrCat
  END;

 Procedure _PStrNCat(Dest: PShortString; Const Src: ShortString; Size: Integer);
  ASM
   JMP RTL_PStrNCat
  END;

 Function _Copy(Const S: ShortString; Index, Count: Integer): ShortString;
  ASM
   JMP RTL_Copy
  END;

 Procedure _Delete(Var S: OpenString; Index, Count: Integer);
  ASM
   JMP RTL_Delete
  END;

 Procedure _Insert(Const Source: ShortString; Var S: OpenString; Index: Integer);
  ASM
   JMP RTL_Insert
  END;

 Procedure _SetLength(S: PShortString; newLength: Byte);
  ASM
   JMP RTL_SetLength
  END;

 Procedure _SetString(S: PShortString; buffer: PAnsiChar; len: Byte);
  ASM
   JMP RTL_SetString
  END;

 //==================
 // RTL Extensions
 //==================

 Procedure RTLExtend_ShortString(Var Ex: TRTLEx_ShortString);
  BEGIN
   _INT_RTL_DoEx(@RTL_PStrCmp, @Ex._PStrCmp);
   _INT_RTL_DoEx(@RTL_PStrCpy, @Ex._PStrCpy);
   _INT_RTL_DoEx(@RTL_PStrNCpy, @Ex._PStrNCpy);
   _INT_RTL_DoEx(@RTL_PStrCat, @Ex._PStrCat);
   _INT_RTL_DoEx(@RTL_PStrNCat, @Ex._PStrNCat);
   _INT_RTL_DoEx(@RTL_Copy, @Ex._Copy);
   _INT_RTL_DoEx(@RTL_Delete, @Ex._Delete);
   _INT_RTL_DoEx(@RTL_Insert, @Ex._Insert);
   _INT_RTL_DoEx(@RTL_SetLength, @Ex._SetLength);
   _INT_RTL_DoEx(@RTL_SetString, @Ex._SetString);
  END;

{$ENDIF Include_Modules_Implement}
(******************)
(* Initialization *)
(******************)
{$IFDEF Include_Modules_Initialize}
{$ENDIF Include_Modules_Initialize}
(****************)
(* Finalization *)
(****************)
{$IFDEF Include_Modules_Finalize}
{$ENDIF Include_Modules_Finalize}
